<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /**
     * @param {string} s
     * @return {string}
     */
    var reverseVowels = function (s) {
      let strArr = s.toLowerCase().split("");
      let vowels = "aeiou";
      let vowelTmp = []; // 保存元音字符
      let vowelIndex = []; // 保存元音字符的下标
      debugger;
      for (let i = 0; i < strArr.length; i++) {
        if (vowels.indexOf(strArr[i]) > -1) {
          //  元音
          vowelTmp.push(strArr[i]);
          vowelIndex.push(i);
        }
      }
      vowelTmp.reverse();
      for (let j = 0; j < vowelIndex.length; j++) {
        strArr.splice(vowelIndex[j], 1, vowelTmp[j]);
      }
      return strArr.join("");
    };
    console.log("reverseVowels()", reverseVowels("hello"));
  </script>
</html>
